import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'


export const constantRouterMap = [
  {path: '/login', component: () => import('@/views/login/index'), hidden: true},
  {path: '/404', component: () => import('@/views/404'), hidden: true},
  // {path: '/register',component:() => import('@/views/register/index'),hidden: false},

  {
    path: '',
    component: Layout,
    redirect: '/home',
    children: [{
      path: 'home',
      name: 'home',
      component: () => import('@/views/home/index'),
      meta: {title: '首页', icon: 'home'}
    }]
  },
  {
    path: '/account',
    component: Layout,
    redirect: '/account/admin',
    meta: {title: '账号', icon: 'account'},
    sort: -10,
    children: [
      {
        path: 'admin',
        name: 'accountAdmin',
        component: () => import('@/views/account/index'),
        meta: {title: '信息修改', icon: 'updateUser'}
      },
      {
        path: 'repwd',
        name: 'repwd',
        component: () => import('@/views/account/repwd'),
        meta: {title: '修改密码', icon: 'pwd'}
      }
    ]
  }
]

export const asyncRouterMap = [

  {
    path: '/pms',
    component: Layout,
    redirect: '/pms/product',
    name: 'pms',
    meta: {title: '商品', icon: 'product'},
    children: [
      {
        path: 'product',
        name: 'product',
        component: () => import('@/views/pms/product/index'),
        meta: {title: '商品列表', icon: 'product-list'}
      },
      {
        path: 'addProduct',
        name: 'addProduct',
        component: () => import('@/views/pms/product/add'),
        meta: {title: '添加商品', icon: 'product-add'}
      },
      {
        path: 'updateProduct',
        name: 'updateProduct',
        component: () => import('@/views/pms/product/update'),
        meta: {title: '修改商品', icon: 'product-add'},
        hidden: true
      },
      {
        path: 'productCate',
        name: 'productCate',
        component: () => import('@/views/pms/productCate/index'),
        meta: {title: '商品分类', icon: 'product-cate'}
      },
      {
        path: 'subject',
        name: 'subject',
        component: () => import('@/views/pms/subject/index'),
        meta: {title: '科目管理', icon: 'product-brand'}
      }

    ]
  },
  {
    path: '/oms',
    component: Layout,
    redirect: '/oms/order',
    name: 'oms',
    meta: {title: '订单', icon: 'order'},
    children: [
      {
        path: 'order',
        name: 'order',
        component: () => import('@/views/oms/order/index'),
        meta: {title: '订单列表', icon: 'product-list'}
      },
      {
        path: 'orderDetail',
        name: 'orderDetail',
        component: () => import('@/views/oms/order/orderDetail'),
        meta: {title: '订单详情'},
        hidden: true
      },

      {
        path: 'orderSetting',
        name: 'orderSetting',
        component: () => import('@/views/oms/order/setting'),
        meta: {title: '订单设置', icon: 'order-setting'}
      },
    ]
  },
  {
    path: '/ums',
    component: Layout,
    redirect: '/ums/admin',
    name: 'ums',
    meta: {title: '权限', icon: 'ums'},
    children: [
      {
        path: 'admin',
        name: 'admin',
        component: () => import('@/views/ums/admin/index'),
        meta: {title: '用户列表', icon: 'ums-admin'}
      },
      {
        path: 'role',
        name: 'role',
        component: () => import('@/views/ums/role/index'),
        meta: {title: '角色列表', icon: 'ums-role'}
      },
      {
        path: 'allocMenu',
        name: 'allocMenu',
        component: () => import('@/views/ums/role/allocMenu'),
        meta: {title: '分配菜单'},
        hidden: true
      },
      {
        path: 'allocResource',
        name: 'allocResource',
        component: () => import('@/views/ums/role/allocResource'),
        meta: {title: '分配资源'},
        hidden: true
      },
      {
        path: 'menu',
        name: 'menu',
        component: () => import('@/views/ums/menu/index'),
        meta: {title: '菜单列表', icon: 'ums-menu'}
      },
      {
        path: 'addMenu',
        name: 'addMenu',
        component: () => import('@/views/ums/menu/add'),
        meta: {title: '添加菜单'},
        hidden: true
      },
      {
        path: 'updateMenu',
        name: 'updateMenu',
        component: () => import('@/views/ums/menu/update'),
        meta: {title: '修改菜单'},
        hidden: true
      },
      {
        path: 'resource',
        name: 'resource',
        component: () => import('@/views/ums/resource/index'),
        meta: {title: '资源列表', icon: 'ums-resource'}
      },
      {
        path: 'resourceCategory',
        name: 'resourceCategory',
        component: () => import('@/views/ums/resource/categoryList'),
        meta: {title: '资源分类'},
        hidden: true
      }
    ]
  },
  {
    path: '/ams',
    component: Layout,
    redirect: '/ams/article',
    name: 'ams',
    meta: {title: '文章', icon: 'article'},
    children: [
      {
        path: 'article',
        name: 'article',
        component: () => import('@/views/ams/article/index'),
        meta: {title: '文章列表', icon: 'article-list'}
      },
      {
        path: 'articleUpdate',
        name: 'articleUpdate',
        component: () => import('@/views/ams/article/update'),
        meta: {title: '修改文章', icon: 'article-update'},
        hidden: true
      },
      {
        path: 'addArticle',
        name: 'addArticle',
        component: () => import('@/views/ams/article/add'),
        meta: {title: '添加文章', icon: 'product-add'},
      }
    ]
  },
  {
    component: Layout,
    path: '/ims',
    redirect: '/ims/swiper',
    name: 'ims',
    meta: {title: '推送', icon: 'article'},
    children: [
      {
        path: 'swiper',
        name: 'swiper',
        component: () => import('@/views/ims/swiper'),
        meta: {title: '首页设置', icon: 'article-list'}
      },
      {
        path: 'addSwiper',
        name: 'addSwiper',
        component: () => import('@/views/ims/addSwiper'),
        meta: {title: '添加轮播图', icon: 'article-list'},
        hidden: true
      },
      {
        path: 'editSwiper',
        name: 'editSwiper',
        component: () => import('@/views/ims/editSwiper'),
        meta: {title: '修改轮播图', icon: 'article-list'},
        hidden: true
      },
      {
        path: 'info',
        name: 'info',
        component: () => import('@/views/ims/info'),
        meta: {title: '商城信息', icon: 'info'}
      },
    ]
  },
  {path: '*', redirect: '/404', hidden: true}
]

export default new Router({
  // mode: 'history', //后端支持可开
  // scrollBehavior: () => ({y: 0}),
  routes: constantRouterMap
})

